﻿<?php  
require_once("BaseDao.php");
require_once("Rc.php");
class RcDao extends BaseDao {

	public function savemess($weeks,$clatime,$message){
			$sth = $this->db->prepare("INSERT INTO richen(week, classtime, message) VALUES (:weeks,:clatime,:message)");
			$sth->bindValue(':weeks', $weeks, PDO::PARAM_STR);
			$sth->bindValue(':clatime', $clatime, PDO::PARAM_STR);
			$sth->bindValue(':message', $message, PDO::PARAM_STR);
			$sth->execute();
			print_r($sth->errorInfo());	
	}

	public function sel($weeks,$clatime){
			$sth = $this->db->prepare("select * from richen where week=:weeks and classtime=:clatime");
			$sth->bindValue(':weeks', $weeks, PDO::PARAM_STR);
			$sth->bindValue(':clatime', $clatime, PDO::PARAM_STR);
			$sth->execute();
			//print_r($sth->errorInfo());
			$array = array();
			while($row = $sth->fetch(PDO::FETCH_ASSOC)){
				$rc = new Rc($row['id'],$row['week'],$row['classtime'],$row['message']);
				$array[] = $rc;
			}
			return $array;	
	}

	public function findall() {
			$sth = $this->db->prepare("select * from richen");
			$sth->execute();
			//print_r($sth->errorInfo());
			$array = array();
			while($row = $sth->fetch(PDO::FETCH_ASSOC)){
				$rc = new Rc($row['id'],$row['week'],$row['classtime'],$row['message']);
				$array[] = $rc;
			}
			return $array;
		}

	public function delid($id){
			$sth = $this->db->prepare("delete from richen where id=:id");
			$sth->bindValue(':id', $id, PDO::PARAM_INT);
			$sth->execute();
			print_r($sth->errorInfo());	
	}

}

//$dao = new RcDao();
//$dao->savemess("q","w","aaaa");
//$dao->delid(15);
	
?>